package com.coreJava.设计模式.原型模式;

import java.io.IOException;
import java.util.HashMap;

/**
 * 作者: LCG
 * 日期: 2019/9/5 11:05
 * 描述:
 */
public class TestYuanXing {

    public static void main(String[] args) throws CloneNotSupportedException, IOException, ClassNotFoundException {

       /* Order order=new Order();
        order.setMap(new HashMap());
        Order clone = order.clone();

        System.out.println(clone.getMap()==order.getMap());

        Order order1 = order.deepClone();

        System.out.println(order.getMap()==order1.getMap());*/




        //克隆和new的性能比对  3647 3541  10.116
    	/*long ll=System.currentTimeMillis();
    	System.out.println("=======开始======="+ll);

    	for(int i=0;i<=1000000000;i++){

    		Order order=new Order();
        	order.setBrandName("米其林");
        	order.setGoodsName("米其林轱辘");
        	order.setQunatity(1);
        	User u=new User();
        	u.setName("燕双鹰");
        	order.setUser(u);
    		order.setMap(new HashMap());

    	}

    	System.out.println("=======结束======="+(System.currentTimeMillis()-ll)/1000.0);*/




        //深克隆性能测试===================================================
       /* long ll=System.currentTimeMillis();
        System.out.println("=======开始======="+ll);
        Order order=new Order();
        order.setBrandName("米其林");
        order.setGoodsName("米其林轱辘");
        order.setQunatity(1);
        User u=new User();
        u.setName("燕双鹰");
        order.setUser(u);
        order.setMap(new HashMap());
        for(int i=0;i<=1000000000;i++){

            Order order11=(Order)order.clone();

        }
        System.out.println("=======结束======="+(System.currentTimeMillis()-ll)/1000.0);*/

    }

}
